﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoccerSimulator5000
{
    public class TeamComparer : IComparer<Team>
    {
        public int Compare(Team team1, Team team2)
        {
            if (team1.standingsData.points > team2.standingsData.points)
            {
                return 1;
            }
            else if (team1.standingsData.points == team2.standingsData.points && team1.standingsData.goalsDiff > team2.standingsData.goalsDiff)
            {
                return 1;
            }
            else if (team1.standingsData.points == team2.standingsData.points && team1.standingsData.gamesWon == team2.standingsData.goalsDiff && team1.standingsData.goalsFor > team2.standingsData.goalsFor)
            {
                return 1;
            }
            else if (team1.standingsData.points == team2.standingsData.points && team1.standingsData.gamesWon == team2.standingsData.goalsDiff && team1.standingsData.goalsFor == team2.standingsData.goalsFor && team1.standingsData.goalsAgainst < team2.standingsData.goalsAgainst)
            {
                return 1;
            }
            else
                return 0;
        }
    }
}
